#!/bin/bash

#配置计算节点支持ceilometer
yum install openstack-ceilometer-compute python2-wsme
cp /etc/ceilometer/ceilometer.conf{,.bak}
settingfile=/etc/ceilometer/ceilometer.conf

#[DEFAULT]
openstack-config --set $settingfile DEFAULT transport_url rabbit://openstack:openstack@controller:5673
openstack-config --set $settingfile DEFAULT auth_strategy keystone

#[keystone_authtoken]
openstack-config --set $settingfile keystone_authtoken auth_uri http://controller:5000
openstack-config --set $settingfile keystone_authtoken auth_url http://controller:35357
openstack-config --set $settingfile keystone_authtoken memcached_servers controller1:11211,controller2:11211,controller3:11211
openstack-config --set $settingfile keystone_authtoken auth_type password
openstack-config --set $settingfile keystone_authtoken project_domain_name default
openstack-config --set $settingfile keystone_authtoken user_domain_name default
openstack-config --set $settingfile keystone_authtoken project_name service
openstack-config --set $settingfile keystone_authtoken username ceilometer
openstack-config --set $settingfile keystone_authtoken password ceilometer

#[service_credentials]
openstack-config --set $settingfile service_credentials auth_type password
openstack-config --set $settingfile service_credentials auth_url http://controller:5000/v3
openstack-config --set $settingfile service_credentials project_domain_name default
openstack-config --set $settingfile service_credentials user_domain_name default
openstack-config --set $settingfile service_credentials project_name service
openstack-config --set $settingfile service_credentials username ceilometer
openstack-config --set $settingfile service_credentials password ceilometer
openstack-config --set $settingfile service_credentials interface internalURL
openstack-config --set $settingfile service_credentials region_name RegionOne

settingfile=/etc/nova/nova.conf

#[DEFAULT]
openstack-config --set $settingfile DEFAULT instance_usage_audit True
openstack-config --set $settingfile DEFAULT instance_usage_audit_period hour
openstack-config --set $settingfile DEFAULT notify_on_state_change vm_and_task_state

#[oslo_messaging_notifications]
openstack-config --set $settingfile oslo_messaging_notifications driver messagingv2

systemctl enable openstack-ceilometer-compute.service
systemctl start openstack-ceilometer-compute.service
systemctl restart openstack-nova-compute.service